cmake_minimum_required(VERSION 3.16)

project(music_player VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)
# find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets)

set(CMAKE_AUTORCC ON)
# set(API_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/api)
# set(DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR})

# message("API_FOLDER:  ${API_FOLDER}")
# message("DESTINATION_FOLDER:  ${DESTINATION_FOLDER}")

qt_add_executable(appmusic_player
    main.cpp
    ImageResource.qrc
    logo.rc
    logo.ico
)

# add_custom_command(
#     TARGET appmusic_player POST_BUILD
#     COMMAND ${CMAKE_COMMAND} -E copy_directory ${API_FOLDER} ${DESTINATION_FOLDER}
#     COMMENT "Copying folder to executable directory"
# )

qt_add_qml_module(appmusic_player
    URI music_player
    VERSION 1.0
    QML_FILES Main.qml
    view/CTitleBar.qml
    view/CBottomBar.qml
    view/CLeftContent.qml
    view/CRightContent.qml
    components/RoundedImage.qml
    components/ToolTipButton.qml
    components/CScrollBar.qml
    components/HoverMouseArea.qml
    components/MusicRow.qml
    pages/PageFindMusic.qml
    pages/PageSongListDetails.qml
    pages/PageCollectMusic.qml
    pages/PageSearchMusic.qml
    content/NewMusicContent.qml
    content/FindMusicContent.qml
    content/RecommendationsContent.qml
    MusicResource.qml
    components/Loading.qml
    components/Loading2.qml
    CommonDb.qml
    MusicContext.qml
    Promise.js
    Utils.js
    Rest.js
    SOURCES apiservice.h apiservice.cpp
    framelesswindow.h framelesswindow.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appmusic_player PROPERTIES
    #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appmusic_player
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(appmusic_player PRIVATE Qt6::Quick)
# target_link_libraries(appmusic_player PRIVATE Qt6::Widgets)

include(GNUInstallDirs)
install(TARGETS appmusic_player
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
